function FloatOperation(){
    //展示几位小数
    this.showDoublePointNum = 2;
    //浮点数相乘
    this.floatMultiplication = function(p1,p2){
        let result
        result = math.multiply(math.bignumber(p1),math.bignumber(p2));
        return result.toNumber();
    }

    //浮点数相除
    this.floatDivision = function(p1,p2){
        let result
        result = math.divide(math.bignumber(p1),math.bignumber(p2));
        return result.toNumber();
    }

    //浮点数相减
    this.floatSubtracting = function(p1,p2){
        let result;
        result = math.subtract(math.bignumber(p1),math.bignumber(p2));
        return result.toNumber();
    }

    //浮点数相加
    this.floatAdd = function(p1,p2){
        let total;
        total = math.add(math.bignumber(p1),math.bignumber(p2));
        return total.toNumber();
    }

    //计算浮点型数据小数个数
    this.getNumOfPointLength = function(p){
        let x = String(p).indexOf(".")+1;//得到小数点的位置
        if(x == 0){
            return 0;
        } else {
            let y = String(p).length - x;//小数点的位数 
            return y;
        }
    }

    //y=kx+b线性方程根据y求x
    this.equationSolutionWithParameterKAndB = function(y,k,b){
        let x = null;
        y = parseFloat(y)
        k = parseFloat(k)
        b = parseFloat(b)
        if(this.isValuable(y) && this.isValuable(k) && this.isValuable(b)){
            if(k != 0){
                if(math){
                    x = this.floatDivision(this.floatSubtracting(y,b),k)
                } else {
                    console.log('当前math对象不存在')
                }
            } else {
                console.log('线性方程k值不能为0')
            }
        } else {
            console.log('计算线性方程参数错误！')
        }
        if(x != null){
            return x;
        } else {
            quakooApp.toast('数据异常');
            return 0;
        }
    }

    //y=kx+b线性方程根据x求y
    this.equationSolutionWithParameterXAndKAndB = function(x,k,b){
        x = parseFloat(x)
        k = parseFloat(k)
        b = parseFloat(b)
        let y = null;
        if(this.isValuable(x) && this.isValuable(k) && this.isValuable(b)){
            if(math){
                y = this.floatAdd(this.floatMultiplication(x,k), b)
            } else {
                console.log('当前math对象不存在')
            }
        } else {
            console.log('计算线性方程参数错误！')
        }
        if(y != null){
            return y;
        } else {
            quakooApp.toast('数据异常');
            return 0;
        }
    }

    //y=kx+b线性方程根据Δy求Δx
    this.equationSolutionWithParameterChangeY = function(changedY,k){
        let changeX = null;
        if(this.isValuable(changedY) && this.isValuable(k)){
            if(k != 0){
                if(math){
                    changeX = this.floatDivision(changedY,k);
                } else {
                    console.log('当前math对象不存在')
                }
            } else {
                console.log('线性方程k值不能为0')
            }
        } else {
            console.log('计算线性方程参数错误！')
        }
        if(changeX){
            return changeX;
        } else {
            quakooApp.toast('数据异常');
            return 0;
        }
    }

    //保留几位小数，其余舍弃
    this.abandonNum = function(num,digit){
        let pow = Math.pow(10,digit)
        num = this.floatMultiplication(num,pow)
        num = Math.floor(num)
        num = this.floatDivision(num,pow)
        return num
    }

    //判断是否为null或者undefaind
    this.isValuable = function(param){
        return (param != null && param != undefined);
    }

    //小数四舍五入
    this.keepDecimalWithPointNum = function(decimal,points){
        return Math.round(Math.pow(10, points) * decimal) / Math.pow(10, points)
    }

    //设置保存的小数位数
    this.saveShowDoublePointNum = function(showDoublePointNum){
        if(showDoublePointNum && isNaN(showDoublePointNum) == false && showDoublePointNum > 0 ){
            this.showDoublePointNum = showDoublePointNum
        }
    }

    //判断小数位数大于两位进行四舍五入展示根据接口
    this.isJudgeDecimalRound = function(num,customRoundDecimal){
        let self = this;
        let showDoublePointNum = customRoundDecimal ? customRoundDecimal : self.showDoublePointNum
        if(num != null){
            let tempNum = parseFloat(num)
            if(isNaN(tempNum)){
                //不是数字,不改变原来逻辑
                return num
            } else {
                //是数字
                let decimalNum = this.getNumOfPointLength(tempNum)
                if(decimalNum > showDoublePointNum){
                    //大于两位小数进行四舍五入
                    return this.keepDecimalWithPointNum(tempNum,showDoublePointNum)
                } else {
                    //不大于两位小数原型返回
                    return tempNum
                }
            }
        } else {
            return ''
        }
    }

    // 判断两个数字是否相等
    this.numsIsSome = function(num1,num2){
        if(isNaN(num1) || isNaN(num2)){
            return false
        } else {
            let isSome = (this.floatSubtracting(num1,num2) == 0)
            return isSome
        }
    }
}